home *** CD-ROM | disk | FTP | other *** search
- {$APPTYPE CONSOLE}
- {$H+,O+}
-
- program IncVer;
-
- uses
- Windows,
- SysUtils,
- IniFiles;
-
- function PosR(subs, s: string): integer;
- var
- i: integer;
- ls: integer;
- begin
- ls := Length(subs);
- if ls <= Length(s) then
- begin
- for i := Length(s)-ls+1 downto 1 do
- begin
- if Copy(s,i,ls) = subs then
- begin
- PosR := i;
- Exit;
- end;
- end;
- end;
- PosR := 0;
- end; { PosR }
-
- procedure IncVersion(dofFile: string);
- var
- ini : TINIFile;
- sBuild: string;
- p : integer;
- begin
- if Pos('\',dofFile) = 0 then dofFile := '.\'+dofFile; // stupid TIniFile opens file in windows dir by default!
- if not FileExists(dofFile) then begin
- Writeln('IncrementVersion 1.0');
- Writeln('file ',dofFile,' does not exist!');
- Halt(1);
- end;
- ini := TIniFile.Create(dofFile);
- try
- Ini.WriteInteger('Version Info','Build',Ini.ReadInteger('Version Info','Build',-1)+1);
- sBuild := Ini.ReadString('Version Info Keys','FileVersion','');
- if sBuild <> '' then begin
- p := PosR('.',sBuild);
- if p > 0 then
- sBuild := Copy(sBuild,1,p) +
- IntToStr(StrToIntDef(Copy(sBuild,p+1,Length(sBuild)-p),-1)+1);
- Ini.WriteString('Version Info Keys','FileVersion',sBuild);
- end;
- finally ini.free; end;
- end; { IncVersion }
-
- procedure Usage;
- begin
- Writeln('IncrementVersion 1.0');
- Writeln('Usage: incver dof_file');
- Halt(1);
- end; { Usage }
-
- begin
- if ParamCount <> 1 then Usage;
- IncVersion(ParamStr(1));
- end.
-
-